home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / FUTILS / FSWAP.DOC < prev    next >
Text File  |  1989-02-19  |  2KB  |  63 lines

  1.                              /\ RKCP /\
  2.                              \/ RKCP \/
  3.  
  4. ********************************************************************
  5. ************************* FSWAP by Rex Kerr ************************
  6. ************************ Copyright (C) 1989 ************************
  7. ********************************************************************
  8.  
  9. This is a tiny unit for Turbo Pascal 5.0, written in assembly
  10. language.  Since it is written in assembler, it is both very small
  11. and very fast.
  12.  
  13. There are just 3 procedures in this unit.
  14.  
  15. ***
  16.  
  17. QSwapB(var a,b : byte);
  18.  
  19. This swaps two bytes.
  20.  
  21. ***
  22.  
  23. QSwapW(var a,b : word);
  24.  
  25. This swaps two words.
  26.  
  27. ***
  28.  
  29. QSwapV(var a,b; len : word);
  30.  
  31. This swaps the first len bytes of a and b.
  32.  
  33. ***
  34.  
  35. That's it.  No more messy procedures like this:
  36.  
  37. procedure SwapW(var a,b : word);
  38. var temp : word;
  39. begin
  40.      temp := a;
  41.      a := b;
  42.      b := temp
  43. end;
  44.  
  45. The three QSwaps are better that pascal things like this on two
  46. counts:
  47. 1) They are faster (about 50% faster with words).
  48. 2) They save stack space, as no temp is needed.
  49.  
  50. Now, it is true that with large records and arrays ( > 50 bytes)
  51. a pascal procedure that declares an entire one of the record or
  52. array is faster.  But is is very stack hungry!  Do your own
  53. benchmarks (if have stack space to spare, and really need the
  54. speed).
  55.  
  56. If I've left anything out, or if something isn't clear, please
  57. contact me via the TP5 Messages section of BPROGA or EasyPlex
  58. on CompuServe.
  59.  
  60. Rex Kerr  71550,3147
  61.  
  62.                              /\ RKCP /\
  63.                              \/ RKCP \/